home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST7-10.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  840b  |  33 lines

  1. ;
  2. ; *** Listing 7-10 ***
  3. ;
  4. ; Adds up the elements of a byte-sized array using
  5. ; base+index addressing inside the loop.
  6. ;
  7.     jmp    Skip
  8. ;
  9. ARRAY_LENGTH    equ    1000
  10. TestArray    db    ARRAY_LENGTH dup (1)
  11. TEST_START_OFFSET equ    200    ;we'll add elements 200-299
  12. TEST_LENGTH    equ    100    ; of TestArray
  13. ;
  14. Skip:
  15.     call    ZTimerOn
  16.     mov    bx,offset TestArray+TEST_START_OFFSET
  17.                 ;build the array start
  18.                 ; offset right into the
  19.                 ; base so we can use
  20.                 ; base+index addressing,
  21.     sub    si,si        ; with no displacement
  22.     sub    ax,ax        ;initialize sum
  23.     sub    dl,dl        ;store 0 in DL so we can use
  24.                 ; it for faster register-
  25.                 ; register adds in the loop
  26.     mov    cx,TEST_LENGTH    ;# of bytes to add
  27. SumArrayLoop:
  28.     add    al,[bx+si]    ;add in the next byte
  29.     adc    ah,dl        ; to the 16-bit sum
  30.     inc    si        ;point to next byte 
  31.     loop    SumArrayLoop
  32.     call    ZTimerOff
  33.